class Solution(object):
    def isValidSudoku(self, board):
        """
        :type board: List[List[str]]
        :rtype: bool
        """
        combine = [str(i) for i in range(1, 10)]
        rows = [set(combine) for _ in range(9)]
        cols = [set(combine) for _ in range(9)]
        grid = [[set(combine) for _ in range(3)] for _ in range(3)]
        diag = [set(combine) for _ in range(2)]

        def place(r, c, value):
            rows[r].remove(value)
            cols[c].remove(value)
            grid[r//3][c//3].remove(value)
        
        for r in range(9):
            for c in range(9):
                if board[r][c]!='.':
                    try:
                        place(r, c, board[r][c])
                    except Exception:
                        return False
        return True